package com.cs.bd.ad.self.request;

import android.content.Context;

import com.cs.bd.ad.AdSdkResultHelper;
import com.cs.bd.ad.bean.AdModuleInfoBean;
import com.cs.bd.ad.manager.AdSdkManager;
import com.facebook.ads.NativeAd;

public class WapsAdsRequest extends BaseAdsRequest {

    private NativeAd nativeAd;

    public WapsAdsRequest(Context mContext, AdSdkManager.ILoadAdvertDataListener mLoadAdvertDataListener) {
        super(mContext, mLoadAdvertDataListener);
        nativeAd = new NativeAd(mContext, mLoadAdvertDataListener);
    }

    @Override
    public void requestAds() {
        nativeAd.loadAd();
        if (nativeAd.isAdLoaded()) {
            AdModuleInfoBean adModuleInfoBean = AdSdkResultHelper.createNativeAds("waps", nativeAd);
            if (null != mLoadAdvertDataListener) {
                mLoadAdvertDataListener.onAdInfoFinish(true, adModuleInfoBean);
            }
            if (null != mOnRequestListener) {
                mOnRequestListener.onFinish();
            }
        } else {
            if (null != mOnRequestListener) {
                mOnRequestListener.onError("waps failed");
            }
        }
    }

    @Override
    public int getAdsType() {
        return ADS_TYPE_WAPS;
    }
}
